/*
 * EquipmentUserInfo.cpp
 *
 *  Created on: May 16, 2012
 *      Author: Lucho0
 */

#include "EquipmentUserInfo.h"
#include "../PlayScenarioPanel.h"

#define CIEN 100
#define CERO 0
#define FIX_BAR_POSITION PROGRESS_BARRA_WIDTH/2 // Hay que restarle la mitad del ancho del default bar 50/2 = 25


EquipmentUserInfo::EquipmentUserInfo(std::string userName, int life,Widget* parent) :
Equipment(USER_INFO, parent) {

	this->progressBar = new ProgressBar(life, 0, 0, parent);

}

EquipmentUserInfo::EquipmentUserInfo(DTOEquipment* dtoEquipment,Widget* parent):
Equipment(dtoEquipment, parent){}

EquipmentUserInfo::~EquipmentUserInfo() {
	delete progressBar;
}

void EquipmentUserInfo::updatePosition(int offsetX,int offsetY) {
	//Calculo la posicion relativa del progress bar
	progressBar->parcel->posX = offsetX - SH_DEFAULT_WIDHT / 2;
	progressBar->parcel->posY = offsetY + SH_DEFAULT_HEIGHT;
}

int EquipmentUserInfo::reduceLife(int value,playElement element) {
	this->progressBar->reducePercent(value);

	return CERO;
}

void EquipmentUserInfo::updateStatus(){
	//Do nothing
}

void EquipmentUserInfo::handleEvent(Event event){
	//DO nothing???
}

void EquipmentUserInfo::showOn(SDL_Surface* surface,int offsetX,int offsetY) {
	updatePosition(offsetX,offsetY);

	progressBar->showOn(surface);
}

DTOEquipment* EquipmentUserInfo::getDTO() {
	return new DTOEquipment(USER_INFO,this->progressBar->getPorcent(),((PlayScenarioPanel*)parent)->getOwner());
}

int EquipmentUserInfo::getLifePorcent(){
	return progressBar->getPorcent();
}
